//
//  WebViewController.m
//  HZHome
//
//  Created by SunShine on 13-10-17.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()

@end

@implementation WebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    NSLog(@"准备装载页面%@",_url);
    
//    [self.webView loadRequest:[NSURL URLWithString:_url]];
    [self loadFileWithName:_name];
//    self.navigationItem.leftBarButtonItem = nil;

}

-(void)loadFileWithName:(NSString *)name
{
    NSString *path = [[NSBundle mainBundle]bundlePath];
    NSURL *baseUrl = [NSURL fileURLWithPath:path];
    NSString *htmlFile = [[NSBundle mainBundle]pathForResource:name ofType:@"html"];
    
    NSLog(@"读取到html文件路径%@",htmlFile);
    NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
    [self.webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseUrl];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
